package dao;

import java.sql.SQLException;
import dto.RegisterDTO;

public class RegisterDAO extends BaseDAO{
	
	public boolean findPower(RegisterDTO rdto){
		boolean flag=false;
		String sql="select * from tb_power where power_code=? and power_pass=?";
		try {
			conn=getConnection();
			ps=conn.prepareStatement(sql);
			ps.setString(1, rdto.getPowerCode());
			ps.setString(2, rdto.getPowerPass());
			rs=ps.executeQuery();
			if(rs.next()){
				flag=true;
				deletePower(rdto);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
		    closeSource(conn, ps, rs);
		}
		return flag;
	}
	
	
	public void deletePower(RegisterDTO rdto){
		String sql="delete from tb_power where power_code=? and power_pass=?";
		try {
			ps=conn.prepareStatement(sql);
			ps.setString(1, rdto.getPowerCode());
			ps.setString(2, rdto.getPowerPass());
			ps.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
